/*************************************************************************************************************************************************************				DESENVOLVEDORES: Denis Tobias; Diogo Oliveira; Marcel M. Marum; Marcos F. Rachid; Rodrigo M. Botelho
*					ORIENTADOR e DESENVOLVEDOR: Prof.Dr. Eraldo Pereira Marinho
*
*							Arquivo: keywords.c
*
************************************************************************************************************************************************************/
#include <string.h>
#include "keywords.h"

//array que guarda as palavras chaves do pascal.
char           *keydictionary[] = {
	"BEGIN",
	"IF",
	"THEN",
	"ELSE",
	"WHILE",
	"DO",
	"REPEAT",
	"UNTIL",
	"FOR",
	"GOTO",
	"TO",
	"DOWNTO",
	"CASE",
	"OF",
	"PROGRAM",
	"VAR",
	"CONST",
	"TYPE",
	"RECORD",
	"SET",
	"VALUE",
	"INTEGER",
	"REAL",
	"BOOLEAN",
	"ARRAY",
	"STRING",
	"DOUBLE",
	"CHAR",
	"FILe",
	"PROCEDURE",
	"FUNCTION",
	"NOT",
	"AND",
	"OR",
	"FALSE",
	"TRUE",
	"MOD",
	"DIV",
	"END"
};

//função procura a palavra key entre as palavras chaves do pascal e retorna o valor int correspondente a palavra chave.
iskeyword(const char *key)
{
    int             i;
    for (i = BEGIN; i < END + 1; i++) {
        if (strcmp(keydictionary[i - BEGIN], key) == 0){
//	    printf("%s, %s, %d\n", keydictionary[i - BEGIN], key, i);
            return i;
	}
    }
    return 0;
}

